from datetime import datetime
from typing import Literal

from pydantic import Field

from src.models.base import IdenticalModel
from src.models.mail import FormerGraduateRecord, FreshGraduateRecord


class PrintRecord(IdenticalModel):
    """打印记录"""

    id: str = Field(title="学号", json_schema_extra={"uneditable": True})
    name: str = Field(title="姓名", json_schema_extra={"uneditable": True})
    education_level: Literal["本科", "硕士", "博士"] = Field(
        title="培养层次", json_schema_extra={"uneditable": True}
    )
    print_type: Literal["应届", "非应届"] = Field(
        title="打印类型", json_schema_extra={"uneditable": True}
    )
    does_print_tongzhi: Literal["是", "否"] = Field(title="是否打印通知单")
    does_print_kuaidi: Literal["是", "否"] = Field(title="是否打印快递单")
    is_printed: Literal["是", "否"] = Field(
        title="是否已打印", json_schema_extra={"uneditable": True}
    )

    @classmethod
    def from_fresh_graduate_record(
        cls, fresh_graduate_record: FreshGraduateRecord
    ) -> "PrintRecord":
        return cls(
            id=fresh_graduate_record.id,
            name=fresh_graduate_record.name,
            education_level=fresh_graduate_record.education_level,
            print_type="应届",
            does_print_tongzhi="是",
            does_print_kuaidi="是",
            is_printed="否",
            last_modified_time=datetime.now(),
            create_time=datetime.now(),
        )

    @classmethod
    def from_former_graduate_record(
        cls, former_graduate_record: FormerGraduateRecord
    ) -> "PrintRecord":
        return cls(
            id=former_graduate_record.id,
            name=former_graduate_record.name,
            education_level=former_graduate_record.education_level,
            print_type="非应届",
            does_print_tongzhi="是",
            does_print_kuaidi="是",
            is_printed="否",
            last_modified_time=datetime.now(),
            create_time=datetime.now(),
        )
